﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Windows.Forms;

namespace StudentApartMentManage
{
    public partial class UsualAdmin : Form
    {
        string uname;
        public UsualAdmin(string uname)
        {
            InitializeComponent();
            this.uname = uname;
        }
        string GetRstr(string sql)
        {
            string str = null;
            string connectionString = ConfigurationManager.ConnectionStrings["con"].ConnectionString;
            SqlConnection con = new SqlConnection(connectionString);
            SqlCommand cmd = new SqlCommand(sql, con);
            con.Open();
            SqlDataReader r = cmd.ExecuteReader();
            if (r.Read())
            {
               str = r.GetString(0);
            }
            r.Close();
            con.Close();
            return str;
        }
        void show(string sql)
        {
        }
        private void UsualAdmin_Load(object sender, EventArgs e)
        {
            string sql = string.Format("select 姓名 from 公寓管理员信息表 where 管理员ID='{0}'", uname);
            Text="你好,"+ GetRstr(sql)+"!";
            

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void 学生信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }




        private void 学生信息添加ToolStripMenuItem_Click(object sender, EventArgs e)
        {

            AddStuInfo addstu = new AddStuInfo();
            addstu.MdiParent = this;
            addstu.Show();
           
            
            

            
        }

        private void 学生信息删除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DelStuInfo delstu = new DelStuInfo();
            delstu.MdiParent = this;
            delstu.Show();
        }

        private void 学生信息修改ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            StuInfoModify mdstu = new StuInfoModify();
            mdstu.MdiParent = this;
            mdstu.Show();
        }

        private void 学生信息查询ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            StuInfoSeek seekstu = new StuInfoSeek();
            seekstu.MdiParent = this;
            seekstu.Show();
        }

        private void 公寓信息添加ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddAMTInfo addam = new AddAMTInfo();
            addam.MdiParent = this;
            addam.Show();
        }

        private void 公寓信息删除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DelAMTInfo delam = new DelAMTInfo();
            delam.MdiParent = this;
            delam.Show();
        }

        private void 公寓信息修改ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ModifyAMTInfo mdam = new ModifyAMTInfo();
            mdam.MdiParent = this;
            mdam.Show();
        }

        private void 公寓信息查询ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SeekAMTInfo seeam = new SeekAMTInfo();
            seeam.MdiParent = this;
            seeam.Show();
        }

        private void 退出账户ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("你真的要退出吗？", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                System.Environment.Exit(System.Environment.ExitCode);
                this.Dispose();
                this.Close();

            }
        }

        private void 关于系统ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AboutSystem absys = new AboutSystem();
            absys.Show();
        }

        private void 手动分配ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ManualAssignment mst = new ManualAssignment();
            mst.MdiParent = this;
            mst.Show();
        }

        private void 自动分配ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AutomaticAllocation ast= new AutomaticAllocation();
            ast.MdiParent = this;
            ast.Show();
        }

        private void 学生退宿ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            StayOut sto = new StayOut();
            sto.MdiParent = this;
            sto.Show();
        }

        private void 电费查询ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ElectricityInquiry eci = new ElectricityInquiry();
            eci.MdiParent = this;
            eci.Show();
        }

        private void 电费缴纳ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            ElectricityPay ecp = new ElectricityPay();
            ecp.MdiParent = this;
            ecp.Show();
        }

        private void 维修登记ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DMR dmr = new DMR();
            dmr.MdiParent = this;
            dmr.Show();
        }

        private void 维修进度查询ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DMS dms = new DMS();
            dms.MdiParent = this;
            dms.Show();
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            Weather wr = new Weather();
            wr.MdiParent = this;
            wr.Show();
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            Search se = new Search();
            se.MdiParent = this;
            se.Show();
        }
    }
}
